using UnityEngine;
using System.Collections;
using System;

public class UITransition
{
//	public GameMode.eGameMode _modeId;
	public UITweenManager[] _transitions;
}

[System.Serializable]
public class UIPanelData
{
	public string _panelId;
	public UIPanel _panel;
}

public class GUIManager : MonoBehaviour 
{
	public UITransition[] _uiTransitions;
	
	public UIPanelData[] _panels;
	protected UIPanel _curPanel;
	
	protected static GUIManager _instance;
	public static GUIManager Instance
	{
		get 
		{
			return _instance;	
		}
	}
	
	void Awake()
	{
		_instance = this;	
		Init ();
	}
	
	void Init()
	{
		foreach(UIPanelData data in _panels)	
		{
			data._panel.gameObject.SetActive(false);	
		}
	}
	
	public void ChangePanel(string panelId)
	{
		if(_curPanel != null)
		{
			_curPanel.gameObject.SetActive(false);	
		}
		
		_curPanel = FindPanelById(panelId);
		
		_curPanel.gameObject.SetActive(true);
	}
	public UIPanel FindPanelById(string panelId)
	{
		foreach(UIPanelData data in _panels)	
		{
			if(data._panelId == panelId)	
			{
				return data._panel;	
			}
		}
		Debug.LogWarning("Not found panel : " + panelId);
		return null;
	}
    //public UITweenManager[] FindTransitionById(GameMode.eGameMode mode)
    //{
    //    foreach(UITransition trs in _uiTransitions)	
    //    {
    //        if(trs._modeId == mode)
    //        {
    //            return trs._transitions;	
    //        }
    //    }
    //    return null;
    //}

    void OnArcadeMode()
    {
        GameManager.Instance.GotoArcadeMode();
    }

    void OnGameOver()
    {
        GameManager.Instance.finishCurState();
    }
}
